﻿
using Maticsoft.BLL;
using Maticsoft.DBUtility;
using Maticsoft.Model;
using System;
using System.Data;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;

public partial class WebPage_Youhui_YiXiaofei : SystemBBasePage
{

    private string sql = " 1=1 and Consume='Y'  ";
    private Maticsoft.BLL.Team team = new Maticsoft.BLL.Team();
    private Maticsoft.Model.Team teamModel = new Maticsoft.Model.Team();
    private int text = Convert.ToInt32(PageIndex.pageIndex);

    private Maticsoft.Model.UserInfo userInfoModel = new Maticsoft.Model.UserInfo();
    private Maticsoft.BLL.UserInfo usin = new Maticsoft.BLL.UserInfo();


    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        this.getYixiaofei();
    }

    private void getYixiaofei()
    {
        StringBuilder builder = new StringBuilder();
        builder.Append("<tr >");
        builder.Append("<th width='100'>编号</th>");
        builder.Append("<th width='500'>项目</th>");
        builder.Append("<th width='180'>用户</th>");
        builder.Append("<th width='80' nowrap>消费时间</th>");
        builder.Append("</tr>");
        StringBuilder builder2 = new StringBuilder();
        int count = 0;
        DataTable table = DbHelperSQL.GetDataTableByPager(this.text, this.AspNetPager1.CurrentPageIndex, "Id desc", this.sql, "Coupon", out count);
        this.AspNetPager1.PageSize = this.text;
        this.AspNetPager1.RecordCount = count;
        if (table.Rows.Count > 0)
        {
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if ((i % 2) != 0)
                {
                    builder2.Append("<tr>");
                }
                else
                {
                    builder2.Append("<tr class='alt'>");
                }
                builder2.Append("<td>" + table.Rows[i]["Id"] + "</td>");
                this.userInfoModel = null;
                this.teamModel = null;
                if ((table.Rows[i]["Team_id"] != null) && (table.Rows[i]["Team_id"].ToString() != ""))
                {
                    this.teamModel = this.team.GetModel(Convert.ToInt32(table.Rows[i]["Team_id"].ToString()));
                }
                if (this.teamModel != null)
                {
                    builder2.Append(string.Concat(new object[] { "<td>", this.teamModel.Id, "&nbsp;(<a class='deal-title' href='/team.aspx?id=", this.teamModel.Id, "' target='_blank'>", this.teamModel.Title, "</a>)</td>" }));
                }
                else
                {
                    builder2.Append("<td>&nbsp;(&nbsp;)</td>");
                }
                if ((table.Rows[i]["User_id"] != null) && (table.Rows[i]["User_id"].ToString() != ""))
                {
                    this.userInfoModel = this.usin.GetModel(Convert.ToInt32(table.Rows[i]["User_id"].ToString()));
                }
                if (this.userInfoModel != null)
                {
                    builder2.Append("<td nowrap>" + this.userInfoModel.Email + "<br/>" + this.userInfoModel.Username + "</td>");
                }
                else
                {
                    builder2.Append("<td nowrap>(暂无用户)</td>");
                }
                builder2.Append("<td nowrap>" + table.Rows[i]["Consume_time"] + "</td>");
                builder2.Append("</tr>");
            }
        }
        this.Literal1.Text = builder.ToString();
        this.Literal2.Text = builder2.ToString();
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "youhuiquan";
        if (base.Request.HttpMethod == "POST")
        {
            if ((this.txtteamid.Text != "") || (this.txtcouponid.Text != ""))
            {
                if (this.txtteamid.Text != "")
                {
                    this.sql = this.sql + " and Team_id=" + this.txtteamid.Text + " ";
                }
                if (this.txtcouponid.Text != "")
                {
                    this.sql = this.sql + " and Id='" + this.txtcouponid.Text + "' ";
                }
            }
            else
            {
                this.sql = " 1=1 and Consume='Y' ";
            }
        }
        this.getYixiaofei();
    }
}

